package com.spring.nio.core.startup;

import com.spring.nio.business.user.dto.UserDTO;
import com.spring.nio.business.user.param.UserUpdateParam;
import com.spring.nio.business.user.service.UserService;
import com.spring.nio.common.BasicConstant;
import com.spring.nio.core.configuration.NioServerBootstrap;
import com.spring.nio.core.event.handler.ReadEventHandler;
import com.spring.nio.util.LocalTime;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
import java.net.Socket;
import java.nio.channels.*;
import java.time.LocalDateTime;
import java.util.Map;
import java.util.Optional;

/**
 * @Auther: YSFY
 * @Date: 2020-11-14 17:09
 * @Pacage_name: om.spring.nio.core.startup
 * @Project_Name: nio-server
 * @Description: 服务上下文管理器
 */

@Slf4j
@SuppressWarnings("all")
public class NioServerContext {

    private static final Object lock = new Object();

    /**F
     * 启动基础服务以及核心服务
     * @return
     * */
    public static void startupServerContext() {
        try {
            // 启动配置服务
            BasicServer.startupBasicServer();

            // 启动核心服务
            CoreServer.startupCoreServer();

            // 3、追加额外处理
            //CoreServer.appendHandler();
        } catch (Exception e) {
            log.error("[" + LocalTime.formatDate(LocalDateTime.now()) + "] NioServerContext | --> 服务启动失败, error = {}", e.getLocalizedMessage());
            e.printStackTrace();
        }
    }
}
